<?php namespace App\Http\Controllers\user;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;
use Input;
use App\Models\Projects;
use App\Models\System;
use Session;
use App;


class IndexController extends Controller {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		// dd(Session::get('user'));
		$project = Projects::where('is_rec_index', 1)->where("verify_state", 1)->take(4)->get();
		$img_project = Projects::where('is_rec_index_big', 1)->where("verify_state", 1);
		if($img_project->count()){
			$img_project = $img_project->get()[0];
		}else{
			$img_project = '';
		}
		$finance_project = Projects::where('is_financing', 1)->take(3)->get();

		$invest = System::where("key", "invest_num")->pluck("value");
		$investIncrease = System::where("key", "invest_increase")->pluck("value");
		$projects = System::where("key", "projects")->pluck("value");
		$projectsIncrease = System::where("key", "project_increase")->pluck("value");
		$success = System::where("key", "success")->pluck("value");
		$successIncrease = System::where("key", "success_increase")->pluck("value");
		$taught = System::where("key", "taught")->pluck("value");
		$taughtIncrease = System::where("key", "taught_increase")->pluck("value");
		$devices = System::where("key", "devices")->pluck("value");
		$devicesIncrease = System::where("key", "device_increase")->pluck("value");
		return view('user.homepage', ['project' => $project, 'imgProject' => $img_project, 'financeProject' => $finance_project, "invest" => $invest, "invest_increase" => $investIncrease, "projects_num" => $projects, "projects_increase" => $projectsIncrease, "success" => $success, "success_increase" => $successIncrease, "taught" => $taught, "taught_increase" => $taughtIncrease, "devices" => $devices, "devices_increase" => $devicesIncrease])->withIsIndex(true);
	}

	// 后台用户列表

	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		//
	}

	public function getProject()
	{


	}

	/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		//
	}

	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
		//
	}

	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		//
	}

	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		//
	}

	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		//
	}

}
